<?php

class room_Model_DbTable_DbRoom extends Zend_Db_Table_Abstract
{

    protected $_name = 'tbl_room';
	//function for getting record user by user_id
    public function selectroom(){
    	$db = new Application_Model_DbTable_DbGlobal();
    	//$db = $this->getAdapter();
    	$sql = "SELECT * From tbl_room";
    	return  $db->getGlobalDb($sql);
    }
    public function getroom($id){
    	$db = $this->getAdapter();
    	$sql = "Select * From tbl_room where room_id =".$id." LIMIT 1";
    	$rows = $db->fetchRow($sql);
		return $rows;
    }
	public function insertroom($arr)
	{ 
		//print_r($arr);exit();
     	$array_data = array(
     			"room_id"	=>	$arr["room_id"],
     			"floor_id"	=>	$arr["floor_id"],
     			"room_name"	=>	$arr["room_name"],				
     			"room_size"	=>	$arr["room_size"],
				"status"	=>	1,
				"description" =>$arr["description"],
     			"ordering" =>$arr["ordering"]
     			);
     	$id=$this->insert($array_data);
     	

	}
	public function updateStatus($arr)
	{
		$array_data = array(
				"room_id"	=>	$arr["room_id"],
				"status"	=>	1
		);
		$where = $this->getAdapter()->quoteInto('room_id=?', $arr["room_id"]);
		//echo $where; exit();
		$this->update($array_data, $where);
			
	}
	public function updateUnStatus($arr)
	{
		$array_data = array(
				"room_id"	=>	$arr["room_id"],
				"status"	=>	0
		);
		$where = $this->getAdapter()->quoteInto('room_id=?', $arr["room_id"]);
		//echo $where; exit();
		$this->update($array_data, $where);
			
	}
	public function updatroom($arr)
	{
			$array_data = array(
     			"room_id"	=>	$arr["room_id"],
				"floor_id"	=>	$arr["floor_id"],
     			"room_name"	=>	$arr["room_name"],				
     			"room_size"	=>	$arr["room_size"],
				"status"	=>	1,
				"description" =>$arr["description"],
				"ordering" =>$arr["ordering"]
     			);
			$where = $this->getAdapter()->quoteInto('room_id=?', $arr["room_id"]);
			$this->update($array_data, $where);
			//print_r($where); exit();
	}
	public function deleteroom($id){
		$db = $this->getAdapter();
		$sql = "Delete From tbl_room Where room_id=".$id;
		$row = $db->query($sql);
		return $row;
	}

}

